package networking.messages.weaponMessages;

import networking.messages.SimpleMessage;
import logic.common.team.Fraction;
import logic.ships.Ship;
import logic.ships.frigate.Frigate;
import logic.ships.hunter.Hunter;
import logic.ships.mothership.MotherShip;
import logic.weapons.Weapon;
import logic.weapons.WeaponType;

public class WeaponAddMessage extends SimpleMessage {
	
	private int weaponIndex, shipIndex;
	private Fraction fraction;
	private String weaponName;
	private WeaponMessageType type;
	private WeaponType weaponType;
	
	public WeaponAddMessage() {
		super();
	}
	
	public WeaponAddMessage(Weapon weapon) {
		this();
		this.weaponIndex = weapon.getID();
		this.fraction = weapon.getShip().getTeam().getFraction();
		this.weaponName = weapon.getName();
		this.shipIndex = weapon.getShip().getID();
		this.weaponType = weapon.getWeaponType();
		
		Ship ship = weapon.getShip();
		if(ship instanceof Hunter) type = WeaponMessageType.HunterWeapon;
		if(ship instanceof MotherShip) type = WeaponMessageType.MotherShipWeapon;
		if(ship instanceof Frigate) type = WeaponMessageType.FrigateWeapon;
	}
	
	public int getWeaponID() { return weaponIndex; }
	
	public Fraction getFraction() { return fraction; }
	
	public String getWeaponName() { return weaponName; }
	
	public WeaponMessageType getType() { return type; }
	
	public WeaponType getWeaponType() { return weaponType; }
	
	public int getObjectID() { return shipIndex; }
}